package com.cgah


/*
Customer Domain Requirements
A Customer represents an account required to list or bid at AuctionHaus. Customers have the following requirements:
Done C-1: Customers have email address, password and created date fields (unit test)
Done C-2: Email address must be a unique field (integration test)
Done C-3: Email address must be of a valid form (*@*.*) (integration test)
Done C-4: Password must be between 6-8 characters (integration test)
*/
class Customer extends com.cgah.User {

	Date createdDate;
	//String userName;

	// customer can have many bids
    static mappedBy = [listings:'seller', winnings:'winner'];
	static hasMany = [listings:Listing, winnings:Listing, bids:Bid];


	static constraints = {
		// must be unique, must be the form *@*.*
		createdDate(nullable: false);
		listings(nullable: true);
        winnings(nullable: true);
	}

    boolean canDelete()
    {
        return ((this.bids == null || this.bids.empty) && (this.listings == null || this.listings.empty))
    }

}
